﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DLM.Infrastructure.Domain;

namespace DLM.Domain.Model
{
    public class BreakAppointment:IValidatableObject,IAggregateRoot
    {
        public int BID { get; set; }
        [Required(ErrorMessage = "请选择正确的用户")]
        [RegularExpression(@"^[0-9]*$", ErrorMessage = "请输入正确的用户编号！")]
        public int UserID { get; set; }

        [Required(ErrorMessage = "请选择正确的活动")]
        [RegularExpression(@"^[0-9]*$", ErrorMessage = "请输入正确的活动编号！")]
        public int PartyID { get; set; }
        public System.DateTime CreateDate { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (string.IsNullOrEmpty(UserID.ToString()))
            {
                yield return new ValidationResult("用户不允许为空!");
            }

            if (string.IsNullOrEmpty(PartyID.ToString()))
            {
                yield return new ValidationResult("活动不允许为空！");
            }
        }
    }
}
